﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;
using Box.BL;
using Box.Entities;
using Microsoft.Practices.Unity;

namespace Box.Api.Controllers
{
    public class VentaController : ApiController
    {
        [Dependency]
        public IVentaBL ventaService { get; set; }
        public List<Venta> Get()
        {
            return ventaService.GetFromVentasByCriterio("");
        }
        public List<decimal> Get(Int32 anio)
        {
            return ventaService.ListVent(anio);
        }
        
        //[ResponseType(typeof(Venta))]
        //public IHttpActionResult Get(Int32 anio)
        //{
        //    var venta = ventaService.GetFromVentasByAnio(anio);
        //    if (venta == null)
        //    {
        //        return NotFound();
        //    }
        //    return Ok(venta);
        //}

        [ResponseType(typeof(Venta))]
        public IHttpActionResult Post(Venta venta)
        {
            ventaService.AddVenta(venta);
            return CreatedAtRoute("DefaultApi", new { id = venta.Id }, venta);
        }
    }
}
